//
//  MainViewController.swift
//  微博
//
//  Created by lixiangzhou on 16/3/8.
//  Copyright © 2016年 lxz. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        addChildViewControllers()
        
        setTabBar()
    }
    
    private func setTabBar() {
        
        tabBar.shadowImage = UIImage.pixImageWithColor(UIColor(white: 0.8, alpha: 1))
        tabBar.backgroundImage = UIImage(named: "tabbar_background")
    }

    private func addChildViewControllers() {
        tabBar.tintColor = UIColor.orangeColor()
        
        addChildViewController(HomeViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(MessageViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(DiscoverViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(ProfileViewController(), title: "我的", imageName: "tabbar_profile")
    }
    
    private func addChildViewController(childController: UIViewController, title: String, imageName: String) {
        
        childController.title = title
        childController.tabBarItem.image = UIImage(named: imageName)
        childController.tabBarItem.selectedImage = UIImage(named: imageName + "_selected")
        
        let nav = UINavigationController(rootViewController: childController)
        
        addChildViewController(nav)
    }

}
